import requests
import os
a_url = 'https://xy118x182x248x66xy.mcdn.bilivideo.cn:4483/upgcxcode/49/40/214644049/214644049_da8-1-30080.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1691409859&gen=playurlv2&os=mcdn&oi=1941972672&trid=0000813195e9a2e946c8a39e90b5e00041f0p&mid=333976465&platform=pc&upsig=1acb4529d1b3eaa70fcf19ce3ef61acd&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&mcdnid=1002731&bvc=vod&nettype=0&orderid=0,3&buvid=3902245F-7ED6-0D91-109A-CFE7C1BBE36168389infoc&build=0&agrr=1&bw=219211&logo=A0000001'
headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
    'Referer': 'https://www.bilibili.com/bangumi/play/ep332658?theme=movie&from_spmid=666.7.recommend.4'
}

video_res = requests.get(a_url, headers=headers)

data_video = video_res.content
with open('纯音频.mp3', 'wb') as f:
    f.write(data_video)

b_url = 'https://xy118x182x248x66xy.mcdn.bilivideo.cn:4483/upgcxcode/49/40/214644049/214644049_da8-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1691409859&gen=playurlv2&os=mcdn&oi=1941972672&trid=0000813195e9a2e946c8a39e90b5e00041f0p&mid=333976465&platform=pc&upsig=ace3c370fd1f85f091180d9aca09346c&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&mcdnid=1002731&bvc=vod&nettype=0&orderid=0,3&buvid=3902245F-7ED6-0D91-109A-CFE7C1BBE36168389infoc&build=0&agrr=1&bw=40397&logo=A0000001'
b_res = requests.get(b_url, headers=headers)
b = b_res.content
with open('纯视频.mp4', 'wb') as f:
    f.write(b)

os.system('ffmpeg -i "纯音频.mp3" -i "纯视频.mp4" -c copy "demo.mp4" ')